﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using CardPlay.Model.CardModel;

namespace CardPlay.Model.GameModel
{
    public sealed class NotifyCardPileChangedEventArgs : EventArgs
    {
        private NotifyCardPileChangedEventArgs(NotifyCollectionChangedAction action)
        {
            Action = action;
        }

        public NotifyCollectionChangedAction Action { get; private set; }

        public int OldStartingIndex { get; private set; }
        public ICollection<Card> OldItems { get; private set; } 

        public int NewStartingIndex { get; private set; }
        public ICollection<Card> NewItems { get; private set; } 

        public static NotifyCardPileChangedEventArgs ForReset()
        {
            return new NotifyCardPileChangedEventArgs(NotifyCollectionChangedAction.Reset);
        }

        public static NotifyCardPileChangedEventArgs ForAdd(ICollection<Card> cards, int index)
        {
            return new NotifyCardPileChangedEventArgs(NotifyCollectionChangedAction.Add)
            {
                NewStartingIndex = index,
                NewItems = cards
            };
        }

        public static NotifyCardPileChangedEventArgs ForRemove(ICollection<Card> cards, int index)
        {
            return new NotifyCardPileChangedEventArgs(NotifyCollectionChangedAction.Remove)
            {
                OldStartingIndex = index,
                OldItems = cards
            };
        }

        public static NotifyCardPileChangedEventArgs ForReplace(ICollection<Card> oldItems, ICollection<Card> newItems)
        {
            return new NotifyCardPileChangedEventArgs(NotifyCollectionChangedAction.Replace)
            {
                OldItems = oldItems,
                NewItems = newItems
            };
        }
    }
}